﻿<%@ Page ValidateRequest="false" Language="C#" AutoEventWireup="true" CodeBehind="MainPrint.aspx.cs" Inherits="Thksoft.BusinessExpansion.Print.MainPrint" %>

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
    </style>
    <script src="/Scripts/jquery.1.11.1.js" type="text/javascript"></script>
    <%--<script type="text/javascript" src="/Scripts/jquery.PrintArea.js"></script>--%>
    <script type="text/javascript" src="/Scripts/jQuery.print.min.js"></script>
    <script type="text/javascript">
        $(function () {
            if (typeof console == "undefined") {
                console = top.console;
            }
            var BROWSER_TYPE = GET_BROWSER_TYPE();
            $("#PRINT_START").on("click", PRINT_START);
            //$("#PRINT_PREVIEW").on("click", PRINT_PREVIEW);
            //$("#PRINT_SET_UP").on("click", PRINT_SET_UP);
            $("#PRINT_PREVIEW").hide();
            $("#PRINT_SET_UP").hide();
            $("#DIV_D").hide();
            function PRINT_SET_UP() {

            }
            function PRINT_PREVIEW() {

            }
            function PRINT_START() {
                var option = {};
                option.Msg = "确定打印?";
                option.Type = "confirm";
                option.YesCallback = function (index, layero) {
                    top.layer.close(index);
                    $("#PRINT_BODY").print({
                        globalStyles: false,
                        mediaPrint: false,
                        stylesheet: "/css/main.css",
                        iframe: false,
                        noPrintSelector: ".avoid-this",
                        prepend: "",
                        append: "",
                        deferred: $.Deferred().done(function () { top.console.log('Printing done', arguments); })
                    });
                };
                option.CancelCallback = function (index, layero) {
                    top.layer.close(index);
                }
                top.MessageBox.Show(option);
                return;
            }
            //获取浏览器类型
            function GET_BROWSER_TYPE() {
                var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
                var isOpera = userAgent.indexOf("Opera") > -1;
                //判断是否Opera浏览器
                if (isOpera) {
                    return "Opera"
                };
                //判断是否Firefox浏览器
                if (userAgent.indexOf("Firefox") > -1) {
                    return "FF";
                }
                //判断是否chorme浏览器
                if (userAgent.indexOf("Chrome") > -1) {
                    return "Chrome";
                }
                //判断是否Safari浏览器
                if (userAgent.indexOf("Safari") > -1) {
                    return "Safari";
                }
                //判断是否IE浏览器
                if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
                    return "IE";
                }
                //判断是否Edge浏览器
                if (userAgent.indexOf("Trident") > -1) {
                    return "Edge";
                };
            };
        });
    </script>
</head>
<body>
    <form runat="server">
        <asp:HiddenField ID="PRINT_KEY" runat="server" />
        <asp:HiddenField ID="PRINT_VALUE" runat="server" />
        <table id="PRINT_HEADER" border="0" cellpadding="3" cellspacing="0" style="width: 100%;">
            <tr>
                <td id="DIV_D" style="background-color: #E6E8EE; height: 30px; vertical-align: middle; border-bottom: gray 1px double;">&nbsp; &nbsp; &nbsp; &nbsp; 打印方向：
                    <asp:DropDownList ID="PRINT_DIRECTION" runat="server">
                        <asp:ListItem Value="true" Selected="true">纵向</asp:ListItem>
                        <asp:ListItem Value="false">横向</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp;
                </td>
                <td style="background-color: #E6E8EE; height: 30px; vertical-align: middle; border-bottom: gray 1px double;"
                    align="right">
                    <input type="button" id="PRINT_START" runat="server" value="打印" title="打印" style="width: 60px; height: 26px; background-color: #E6E8EE;" />
                    <input type="button" id="PRINT_PREVIEW" runat="server" value="打印预览" title="打印预览"
                        style="width: 80px; height: 26px; background-color: #E6E8EE;" />
                    <input type="button" id="PRINT_SET_UP" runat="server" value="打印页面设置" title="打印页面设置"
                        style="width: 110px; height: 26px; background-color: #E6E8EE;" />
                    &nbsp; &nbsp; &nbsp; &nbsp;
                </td>
            </tr>
        </table>
        <div id="PRINT_BODY" runat="server">
            <table id="PRINT_TABLE" runat="server">
                <tr>
                    <td colspan="2"></td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>